package itheima.d01;

import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

/**
 * 目标：创建客户端，发送数据给服务端
 */
public class Client {

    public static void main(String[] args) throws Exception {

        Scanner scanner = new Scanner(System.in);
        //1.创建客户端Socket对象，与指定的服务器端建立连接（通信管道）
        Socket clientScoket = new Socket("127.0.0.1",10086);

        //2.获取Socket的输出流对象
        OutputStream os = clientScoket.getOutputStream();
        PrintWriter pw = new PrintWriter(os);
        while (true) {
            System.out.println("请输入要发送的数据：");
            String msg = scanner.next();
            //3.写数据给服务器
            pw.println(msg);


        }




    }
}
